<?php
if (! defined ( 'BASEPATH' ))
	exit ( 'No direct script access allowed' );
class Home extends MX_Controller {

	function __construct() {
		parent::__construct ();


		$_SESSION ['KCFINDER'] = array ();
		$_SESSION ['KCFINDER'] ['disabled'] = false;

		$this->load->library ( 'ckeditor', array ('instanceName' => 'CKEDITOR1', 'basePath' => base_url () . "ckeditor/", 'outPut' => true ) );
		$this->load->model ( 'home_model' );
//		$this->load->helper(array('url','language'));
		$this->load->model ( '../../about/models/about_model' );
		$this->load->model ( '../../gallery/models/gallery_model' );
		$this->load->model ( '../../categories/models/categories_model' );
		$this->load->model ( '../../news/models/news_model' );
		$this->load->model ( '../../links/models/links_model' );
		$this->load->model ( '../../lienhe/models/lienhe_model' );
	}

	function index(){
		$language = ($this->uri->segment ( 3 ) == '') ? 0 : $this->uri->segment ( 3 );
		if ($language!=''){
			$this->session->set_userdata('language', $language);
			if ($language=='vietnamese'){
				$this->session->set_userdata('data_language', '');
			}else {
				$this->session->set_userdata('data_language', '_en');
			}
			redirect ( 'home' );
		}
		if (!isset($this->session->userdata['language'])){
			$this->session->userdata['language']='';
			$this->session->set_userdata('data_language', '');
		}
		$this->lang->load('system', $this->session->userdata['language']);

		$categories = $this->categories_model->getCategoriesList ();
		$data ['categories'] = $categories;
		$data ['videos'] = $this->gallery_model->getlistvideo();
		$data ['content'] = 'default';
		$this->load->view ( 'front_end/index', $data );
	}
	function headerData() {
		$categories = $this->categories_model->getCategoriesList ();
		$data ['categories'] = $categories;

		$news = $this->news_model->getlastestnew ();
		$data ['news'] = $news;

		$links = $this->links_model->getlinks ();
		$data ['links'] = $links;

		$data ['company'] = $this->home_model->getCompanyDetail();
		$data ['logo'] = $this->home_model->getLogo();
		$data ['banners'] = $this->home_model->getBanner();
		$data ['photos'] = $this->gallery_model->getRandomPhoto();

		$data ['lienhe'] = $this->lienhe_model->getlienhe();
		$data ['video'] = $this->gallery_model->getHompageVideo();
		return $data;
	}
}